/*
    Copyright 2009 Barnet Wagman

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 */

package ot;

/** Uniquely identifies the location of an object or directory.  A <tt>Loc</tt>
 *  consists of a {@link Context} and a {@link Path}. A <tt>Path</tt>
 *  is an array of strings that (like the elements of a pathname) that
 *  uniquely identify an object or directory within a <tt>Context</tt>.
 *  A <tt>Context</tt>
 *  is implementation dependent.  E.g. for an S3 implementation it is
 *  the bucketname; for a file in a local file system it is the
 *  directory that contains the root of a tree.
 *
 * @author Barnet Wagman
 */
abstract public class Loc implements java.io.Serializable {

    static final long serialVersionUID = ConstantsOt.UID_VERSION;
   
    public Context context;
    
    public Loc(Context context, Path path) {
        this.context = context;
        setPath(path);
    }

    public Context getContext() { return(context); }

    public boolean equals(Object other) {
        if ( !(other instanceof Loc) ) return(false);
        else return( ((Loc) other).context.equals(context) &&
                     ((Loc) other).getPath().equals(getPath()) );
    }

    public String toString() {
        return("Context=" + context + " path=" + getPath());
    }

    abstract public void setPath(Path path);
    abstract public Path getPath();
}
